Python/Dictionary Python MCQ set 1 Sample Test,Sample questions

Question:
 The following code will return data as ______________

1.List

2.Tuple

3.Dictionary

4.None of the above

Posted Date:-2021-12-06 17:29:53


Question:
1,2,3 are the ______________ in the following dictionary.
D = {1 : “One”, 2 : “Two”, 3 : “Three”}

1.Keys

2.Values

3.Items

4.None of the above

Posted Date:-2021-12-06 17:21:58


Question:
A = {“A” : “Apple”, “B” : “Ball”, “C” : “Cat”}
Which of the following statement will return : dict_items([(‘A’, ‘Apple’), (‘B’, ‘Ball’), (‘C’, ‘Cat’)])

1.print(A.keys( ))

2.print(A.values( ))

3.print(A.Items( ))

4.print(A.get( ))

Posted Date:-2021-12-06 18:12:28


Question:
All elements in dictionary are separated by _________

1.Semicolon(;)

2.Comma( ,)

3.Semicolon(;)

4.dot(.)

Posted Date:-2021-12-06 17:19:32


Question:
Choose the correct statement
Assertion (A)  : Items in dictionaries are unordered.
Reason (R) : We may not get back the data in the same order in which we had entered the data initially in        
                    the dictionary.

1.A is true but R is false

2.A is false but R is true

3.Both A and R are false

4.Both A and R are true and R is the correct explanation of A

Posted Date:-2021-12-06 17:56:21


Question:
Choose the correct statement :
Statement A : Dictionaries are mutable.
Statement B : Contents of the dictionary can not changed after it has been created

1.Statement A is True

2.Statement B is True

3.Both the statements are True

4.Statement A is True and Statement B is False

Posted Date:-2021-12-06 18:03:07


Question:
Dictionaries in python are _______

1.Mutable data type

2.Non-Mutable data type

3.Mapping data type

4.Both a and c

Posted Date:-2021-12-06 16:03:43


Question:
Dictionary is a ___________ data type.

1.Sequence

2.Mapping

3.Ordered

4.None of the above

Posted Date:-2021-12-06 16:06:37


Question:
Following statement return values in the form of _______
>>> D1.keys() #D1 is a dictionary

1.tuple

2.list

3.string

4.dictionary

Posted Date:-2021-12-06 18:09:53


Question:
In dictionary Keys and values are separated by ________________

1.Colon (:)

2.Comma( ,)

3.Semicolon(;)

4.dot(.)

Posted Date:-2021-12-06 17:17:34


Question:
Key – value concept is in ____

1.List

2.String

3.Dictionary

4.Tuple

Posted Date:-2021-12-06 17:15:21


Question:
Keys in dictionary are _____________ .

1.Mutable

2.Immutable

3.antique

4.integers

Posted Date:-2021-12-06 17:23:15


Question:
Keys of dictionary must be _______________

1.antique

2.unique

3.mutable

4.integers

Posted Date:-2021-12-06 13:49:55


Question:
pop( ) function delete and ____ the element of dictionary.

1.display

2.return

3.not return

4.add

Posted Date:-2021-12-06 17:46:36


Question:
The following code is an example of _______
N = {A: {'name': 'Ravi', 'age': '5', 'sex': 'M'}, B: {'name': 'Golu', 'age': '2', 'sex': 'F'}}

1.Normal Dictionary

2.Nested Dictionary

3.Empty Dictionary

4.All the above

Posted Date:-2021-12-06 17:43:51


Question:
The key-value pair in dictionary is called ____

1.item

2.pair item

3.paired value

4.value

Posted Date:-2021-12-06 17:55:18


Question:
Traversing a dictionary can be done using ____________

1. if statement

2.loop

3.jump statement

4.None of the above

Posted Date:-2021-12-06 17:28:22


Question:
What type of error is returned by the following code :
a={'a' : "Apple", 'b' : "Banana" , 'c' : "Cat"}
print(a[1])

1.KeyError

2.KeyNotFoundError

3.NotFoundError

4.Syntax Error

Posted Date:-2021-12-06 17:24:27


Question:
Which function helps to merge dictionary ‘D1’ and ‘D2’?

1.merge( )

2.append( )

3.update( )

4. get( )

Posted Date:-2021-12-06 18:18:04


Question:
Which of the following are immutable data type?
a. String
b. Tuple
c. List
d. Dictionary

1.a and c

2. b and d

3.a and b

4.c and d

Posted Date:-2021-12-06 18:14:34


Question:
Which of the following function create a dictionary from a sequence of key-value pairs

1.dictionary( )

2.dict( )

3.create( )

4.convert( )

Posted Date:-2021-12-06 18:08:39


Question:
Which of the following is an example of dictionary?

1.L = [ ]

2.C = ( )

3.D = { }

4.None of the above

Posted Date:-2021-12-06 17:20:26


Question:
Which of the following is feature of Dictionary?

1.Keys are unique within a dictionary.

2.Keys are unique within a dictionary.

3.Dictionary is mutable.

4.All of the above

Posted Date:-2021-12-06 18:11:05


Question:
Which of the following is feature of Dictionary?

1.Keys are unique within a dictionary.

2.Keys are unique within a dictionary.

3.Dictionary is mutable.

4.All of the above

Posted Date:-2021-12-06 18:11:19


Question:
Which of the following is feature of Dictionary?

1.Keys are unique within a dictionary.

2.Keys are unique within a dictionary.

3.Dictionary is mutable.

4.All of the above

Posted Date:-2021-12-06 18:11:22


Question:
Which of the following is feature of Dictionary?

1.Keys are unique within a dictionary.

2.Keys are unique within a dictionary.

3.Dictionary is mutable.

4.All of the above

Posted Date:-2021-12-06 18:11:26


Question:
Which of the following is feature of Dictionary?

1.Keys are unique within a dictionary.

2.Keys are unique within a dictionary.

3.Dictionary is mutable.

4.All of the above

Posted Date:-2021-12-06 18:11:26


Question:
Which of the following is feature of Dictionary?

1.Keys are unique within a dictionary.

2.Keys are unique within a dictionary.

3.Dictionary is mutable.

4.All of the above

Posted Date:-2021-12-06 18:11:26


Question:
Which of the following is feature of Dictionary?

1.Keys are unique within a dictionary.

2.Keys are unique within a dictionary.

3.Dictionary is mutable.

4.All of the above

Posted Date:-2021-12-06 18:11:26


Question:
Which of the following is feature of Dictionary?

1.Keys are unique within a dictionary.

2.Keys are unique within a dictionary.

3.Dictionary is mutable.

4.All of the above

Posted Date:-2021-12-06 18:11:32


Question:
Which of the following is not method of dictionary?

1.len( )

2.pop( )

3.del ( )

4.update( )

Posted Date:-2021-12-06 17:48:02


Question:
Which of the following is used to delete an element from Dictionary?

1.pop( )

2.delete

3.remove

4.None of the above

Posted Date:-2021-12-06 16:04:39


Question:
Which statement is not correct in reference to the following code?
A = {1 : "One", 2 : "Two", 3 : "Three"}
A[4] = "Four"

1.It will add value at the end of dictionary.

2.It will modify value if the key already exist.

3.It will add value in between of the dictionary.

4.All the above

Posted Date:-2021-12-06 17:40:51


Question:
Which statement is used to create an empty dictionary?
a. 

1.d1 = { }

2.d1 = ( )

3. d1 = dict{ }

4.d1 = [ ]

Posted Date:-2021-12-06 16:06:04


Question:
Write the output of the following :
A = {"A" : "Apple", "B" : "Ball", "C" : "Cat"}
print(A.get("D"))

1.KeyNotFoundError

2.Name Error

3.Type Error

4.None

Posted Date:-2021-12-06 18:17:14


Question:
Write the output of the following :
A = {1 : "One", 2 : "Two", 3 : "Three"}
print("One" in A)

1.True

2.False

3.Error

4.One

Posted Date:-2021-12-06 18:04:39


Question:
Write the output of the following :
d1 = {"a" : 50, "b" : 50}
d2 = {"a" : 500, "b" : 50}
print(d1 > d2)

1.True

2.False

3.Error

4.None of the above

Posted Date:-2021-12-06 16:07:29


Question:
Write the output of the following code :
A = {1 : "One", 2 : "Two", 3 : "Three"}
B = {'A' : "Apple", 'B' : "Bat", 'C' : "Cat", 'D' : "Doll"}
A.update(B)
#print(B.values())
print(B)

1. {‘A’ : ‘Apple’ , ‘B’ : ‘Bat’ , ‘C’ : ‘Cat’ , ‘D’ : ‘Doll’}

2.{1 : “One” , 2 : “Two” , 3 : “Three”}

3.{1: ‘One’ , 2: ‘Two’ , 3: ‘Three’ , ‘A’: ‘Apple’ , ‘B’: ‘Bat’ , ‘C’: ‘Cat’ , ‘D’: ‘Doll’}

4.None of the above

Posted Date:-2021-12-06 17:32:08


Question:
Write the output of the following code :
A = {1 : "One", 2 : "Two", 3 : "Three"}
B = {'A' : "Apple", 'B' : "Bat", 'C' : "Cat", 'D' : "Doll"}
print(A.get(4,"Key Not Found"))

1.KeyError

2.Key Not Found

3.None

4.Syntax Error

Posted Date:-2021-12-06 17:35:02


Question:
Write the output of the following code :
A = {1 : "One", 2 : "Two", 3 : "Three"}
print(A[2] + A[1])

1.Error

2.TwoOne

3.21

4.{1 : “One”, 2 : “Two”, 3 : “Three”}

Posted Date:-2021-12-06 17:50:30


Question:
Write the output of the following code :
a={'a' : "Apple", 'b' : "Banana" , 'c' : "Cat"}
a['a']="Anar"
print(a)

1.{‘a’: ‘Anar’, ‘b’: ‘Banana’, ‘c’: ‘Cat’}

2.Error

3.{‘a’ : “Apple, ‘a’: ‘Anar’, ‘b’: ‘Banana’, ‘c’: ‘Cat’}

4.None of the above

Posted Date:-2021-12-06 17:26:07


Question:
Write the output of the following:
A = {1 : "One", 2 : "Two", 3 : "Three"}
B = {'A' : "Apple", 'B' : "Bat", 'C' : "Cat", 'D' : "Doll"}
for i in A:
    print(i)

1.1 2 3

2.1 2 3

3.{1 : “One”, 2 : “Two”, 3 : “Three”}

4.None of the above

Posted Date:-2021-12-06 17:39:24


Question:
_______ datatype fall under mapping

1.List

2.Tuple

3.Dictionary

4.String

Posted Date:-2021-12-06 17:52:56


Question:
_______ is the suitable data type for keys of dictionary in python.

1.Number

2.String

3.Tuple

4.All the above

Posted Date:-2021-12-06 17:57:18


Question:
_________ function returns the number of key: value pairs of the dictionary.

1.total( )

2.len( )

3.length( )

4.items( )

Posted Date:-2021-12-06 18:06:20


Question:
_________ function returns the value corresponding to the key passed as the argument.

1.get( )

2.values( )

3.update( )

4.update( )

Posted Date:-2021-12-06 18:15:50


More MCQS

  1. Python MCQS - Function
  2. Python MCQS - GUI in python
  3. Python MCQS - Operators
  4. Python MCQS - Data type in python
  5. Python MCQS - loops in python
  6. Python MCQS - Numpy
  7. Python MCQS - sqlite3
  8. Python MCQS - Library
  9. Python MCQS - Pandas
  10. Python MCQs
  11. Dictionary Python MCQ set 1
  12. Dictionary Python MCQ set 2
  13. MCQ For Python Fundamentals
  14. MCQ Introduction to Python Section 1
  15. MCQ Introduction to Python Section 2
  16. MCQ Introduction to Python Section 3
  17. MCQ on Flow of Control in Python Set 1
  18. MCQ on Flow of Control in Python Set 2
  19. MCQ on Python String Set 1
  20. File Handling in Python section 1
  21. File Handling in Python section 2
  22. Python Functions MCQS Set 1
  23. Python Functions MCQS Set 2
  24. MCQ on List in Python
  25. Pandas MCQ Questions Set 1
  26. Pandas MCQ Questions Set 2
  27. Tuple MCQ in Python
  28. Python dataframe MCQ
  29. Python Mcq Set 1
  30. Python Mcq Set 2
  31. Python Mcq Set 3
  32. Python Mcq Set 4
  33. Python Mcq Set 5
  34. Python Mcq Set 6
  35. Python Mcq Set 7
  36. Python Mcq Set 8
  37. Python Mcq Set 9
  38. Python Mcq Set 10
  39. Python Mcq Set 11
  40. Python Mcq Set 12
  41. Python Mcq Set 13
  42. Python Mcq Set 14
  43. Python Mcq Set 15
  44. Python Mcq Set 16
  45. Python Mcq Set 17
  46. Python Mcq Set 18
  47. Python Mcq Set 19
  48. Python Mcq Set 20
  49. Python Mcq Set 21
  50. Python MCQ
  51. Python MCQ Questions with Answer
  52. Test
  53. python mcq question and answer
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!